//========encoding:utf-8=========
/*
 * @describe:  
 * @author:cjgong
 * @copyright:chinasoft.cn
 * @date:2020年1月17日 上午10:49:54 
 */

package edu.chinasoft.service;

import org.apache.log4j.Logger;

import edu.chinasoft.dao.UserDao;
import edu.chinasoft.dao.UserDaoImp;
import edu.chinasoft.exception.UserNoExistsException;
import edu.chinasoft.pojo.PageUtilForUser;
import edu.chinasoft.pojo.User;

public class UserServiceImp implements UserService {
	private Logger logger = Logger.getLogger(UserServiceImp.class);
	private UserDao userDao = new UserDaoImp();

	@Override
	public User addUser(User user) {
		logger.debug("UserServiceImp>>>addUser  start ……");
		User result = userDao.insertTable(user);
		logger.debug("UserServiceImp>>>addUser  end ……");
		return result;
	}

	@Override
	public PageUtilForUser findUser(int currentPage, int pageUtil) {
		logger.debug("UserServiceImp>>>findGoods  start ……");
		PageUtilForUser result = userDao.selectTablePage(currentPage, pageUtil);

		logger.debug("UserServiceImp>>>findGoods  end ……");
		return result;
	}
	@Override
    public User  findUserInfo(User user) {
    	logger.debug("UserServiceImp>>>findUserInfo  start ……");
    	User result = this.userDao.selectUserById(user);
    	logger.debug("UserServiceImp>>>findUserInfo  start ……");
    	return result;
    }
	@Override
    public boolean  modifyUserInfo(User user) {
    	logger.debug("UserServiceImp>>>modifyUserInfo  start ……");
    	boolean result = this.userDao.updateUserById(user);
    	logger.debug("UserServiceImp>>>modifyUserInfo  start ……");
    	return result;
    }
	@Override
    public boolean  deleteUserInfo(User user) {
    	logger.debug("UserServiceImp>>>deleteUserInfo  start ……");
    	boolean result = this.userDao.deleteUserById(user);
    	logger.debug("UserServiceImp>>>deleteUserInfo  start ……");
    	return result;
    }
	@Override
	public User  loginUser(User user) throws UserNoExistsException{
		logger.debug("UserServiceImp>>>loginUser  start ……");
		User result = this.userDao.selectUserByNameAndPassword(user);
		logger.debug("UserServiceImp>>>loginUser  end ……");
		return result;
	}
}
